import {computed, ref} from 'vue'
import {defineStore} from 'pinia'

export const useGoodsStore = defineStore('goods', () => {
    const goods = ref(null)
    //返回token
    const goodsInfo = computed(() => goods.value);

    //更新token
    function updateGoods(g) {
        goods.value = g;
    }

    //重置token
    function $reset() {
        goods.value = null;
    }

    return {goods, goodsInfo, updateGoods, $reset};
}, {
    persist: {
        key: 'goods',
        storage: sessionStorage,
    }
});
